<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-27
 * Time: 上午9:21
 */

namespace Admin\Model;

use Think\Model;

class OrderModel extends Model{





    protected $_auto = array (
        array('addtime','time',1,'function'),
    );

    public function search()
    {
        $where=1;
        if($search = I('get.search')){
            $where .= ' AND gname OR content LIKE "%'.$search.'%"';}
        $perpage = 10;
        // 获取总的记录数
        $totalRecord = $this->where($where)->count();
        // 生成翻页的对象
        $page = new \Think\Page($totalRecord, $perpage);
        $page->setConfig('next','下一页');
        $page->setConfig('prev','上一页');
        return array(
            'data' => $this->limit($page->firstRow, $page->listRows)->
                    where($where)->
                    order('id desc')->select(),
            'page' => $page->show(), // 翻页的字符串
        );
    }


} 